﻿#ifndef AXISWIDGET_H
#define AXISWIDGET_H

#include <QWidget>
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
#include <QCheckBox>

class AxisWidget : public QWidget
{
    Q_OBJECT
public:
    explicit AxisWidget(QWidget *parent = nullptr);
    void initGui();
public slots:
    void setPos(int32_t theoryPos[], int32_t encoderPos[]);
    void setLimitStatus(unsigned short axis, bool llimit, bool rlimit, bool home);

private slots:
    void onGoto();
    void onMoveForward();
    void onMoveForwardStop();
    void onMoveBackward();
    void onMoveBackwardStop();
    void onAbort();
    void onClear();
    void onGoHome();
signals:

    void do_jog(unsigned short axis, int dir);
    void do_stop(unsigned short axis);
    void do_abort();
    void do_zero(unsigned short axis, int32_t pos);
    void do_home(unsigned short axis);
    void moveTo(unsigned short axis, int32_t pos);
    void speedChanged(unsigned short axis, int speed);
    void accChanged(unsigned short axis, int acc);
    void decChanged(unsigned short axis, int dec);
private:
    QPushButton * m_pPushButtonBackward[8];
    QPushButton * m_pPushButtonForward[8];
    QPushButton * m_pPushButtonGoto[8];
    QPushButton * m_pPushButtonHome[8];
    QPushButton * m_pPushButtonClear[8];

    QLabel * m_pLabelTheoryPos[8];
    QLabel * m_pLabelEncoderPos[8];

    QLineEdit * m_pLineEditSpeed[8];
    QLineEdit * m_pLineEditAcc[8];
    QLineEdit * m_pLineEditDcc[8];
    QLineEdit * m_pLineEditTargetPos[8];

    QCheckBox * m_pCheckBoxEnable[8];
    QCheckBox * m_pCheckBoxPLimit[8];
    QCheckBox * m_pCheckBoxNLimit[8];
    QCheckBox * m_pCheckBoxHome[8];

};

#endif // AXISWIDGET_H
